﻿@using Microsoft.Extensions.Options
@using CodeSpirit.Web.Options
@inject IOptions<SiteSettings> SiteOptions
@{
    var cdnEnabled = SiteOptions.Value.EnableCdn;
    var resourceBase = cdnEnabled ? SiteOptions.Value.CdnUrl : "";
    var sdkVersion = "6.13.0";
}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <title>@ViewData["Title"] - @Html.Raw(SiteOptions.Value.SiteName)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

    <!-- 样式表 -->
    <resource path="sdk/@(sdkVersion)/antd.css" type="css" />
    <resource path="sdk/@(sdkVersion)/helper.css" type="css" />
    <resource path="sdk/@(sdkVersion)/iconfont.css" type="css" />
    <resource path="css/chat.css" type="css" />

    <!-- 全局变量配置 -->
    <script>
        @{
                var isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development";
        }
        // 初始化全局命名空间
        window.CodeSpirit = window.CodeSpirit || {};

        window.webHost = '@(isDevelopment ? "https://localhost:7120" : SiteOptions.Value.WebHost)';

        // 站点配置
        window.siteSettings = {
            siteName: '@Html.Raw(SiteOptions.Value.SiteName)',
            topSiteName: '@Html.Raw(SiteOptions.Value.TopSiteName)',
            clientAppName: '@Html.Raw(SiteOptions.Value.TopSiteName) | @Html.Raw(SiteOptions.Value.SiteName)',
            logoUrl: '@SiteOptions.Value.LogoUrl',
            cdnEnabled: @(cdnEnabled ? "true" : "false"),
            cdnUrl: '@SiteOptions.Value.CdnUrl',
            resourceBase: '@resourceBase'
        };
    </script>

    <!-- 脚本 -->
    <resource path="sdk/@(sdkVersion)/sdk.js" type="js" />
    <resource path="js/history.js" type="js" />
    @RenderSection("Head", required: false)  <!-- 可选的 Razor section -->
    @await RenderSectionAsync("Styles", required: false)
</head>
<body>
    <div class="page-container">
        @RenderBody()  <!-- 页面主体内容 -->
    </div>
    <resource path="js/token-manager.js" type="js" />
    @await RenderSectionAsync("Scripts", required: false)
    <script src="_framework/blazor.server.js"></script>
    <resource path="js/chat.js" type="js" />
</body>
</html>
